<template >
  <div class="homeSetUp-container">
    <breadcrumb style="position: absolute;width:100%;"></breadcrumb>
    <div class="content">
      <div class="query">
        <div class="margin_right_20">
          用户ID:&nbsp;
          <el-input
            v-model="userNo"
            placeholder="请输入内容"
            style="width:100px;height:30px;"
            @keyup.enter.native="get_goodsList(1)"
          ></el-input>
        </div>
        <div class="margin_right_20">
          会员卡状态:&nbsp;
          <el-select v-model="status" style="width: 100px;">
            <el-option
              v-for="item in options2"
              :key="item.value2"
              :label="item.label"
              :value="item.value2"
            ></el-option>
          </el-select>
        </div>
        <div class="btn">
          <el-button type="primary" icon="el-icon-search" @click="get_goodsList(1)">查询</el-button>
        </div>
      </div>
      <div class="table">
        <el-table :data="couponList" style="width: 100%" height="598">
          <el-table-column prop="userNo" label="用户ID"></el-table-column>
          <el-table-column prop="startTime" label="会员开始时间"></el-table-column>
          <el-table-column prop="endTime" label="会员过期时间"></el-table-column>
          <el-table-column prop="overdue" label="会员卡状态"></el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button type="text" size="small" @click="jump_goods_detail(scope.row.id)">会员开通记录</el-button>
            </template>
          </el-table-column>
        </el-table>
        <pagination
          :currentPage="currentPage"
          :page="page"
          :total="total"
          :pageSize="pageSize"
          @change-current="currentChange"
          @change-size="sizeChange"
        ></pagination>
      </div>
    </div>
  </div>
</template>
<script>
import breadcrumb from "../../components/breadcrumb";
import pagination from "../../components/page";
import { coupon_list, coupon_delete } from "../../api/getData.js";
export default {
  components: { breadcrumb, pagination },
  data() {
    return {
      userNo: "",
      status: "0",
      currentPage: 1,
      total: 0,
      time: "",
      couponList: [],

      options2: [
        {
          value2: "0",
          label: "全部"
        },
        {
          value2: "1",
          label: "有效"
        },
        {
          value2: "2",
          label: "过期"
        }
      ],

      page: 1,
      pageSize: 10
    };
  },
  props: ["positionsId"],
  created() {
    if (localStorage.getItem("pageMsg")) {
      let pageMsg = JSON.parse(localStorage.getItem("pageMsg"));
      this.userNo = pageMsg.userNo;
      this.status = pageMsg.userNo;
      this.currentPage = pageMsg.currentPage;
      this.pageSize = pageMsg.pageSize;
      localStorage.removeItem("pageMsg");
    }
    this.get_goodsList();
  },
  methods: {
    sizeChange(val) {
      this.pageSize = val;
      this.currentPage = 1;
      this.get_goodsList();
    },
    currentChange(val) {
      this.currentPage = val;
      this.get_goodsList();
    },

    jump_goods_detail(id) {
      localStorage.setItem("path", JSON.stringify(this.$route.path));
      localStorage.setItem(
        "pageMsg",
        JSON.stringify({
          userNo: this.userNo,
          status: this.status,
          currentPage: this.currentPage,
          pageSize: this.pageSize
        })
      );

      this.$router.push("memberOpenList?id=" + id);
    },
    get_goodsList(currentPage) {
      let data =
        "userNo=" +
        this.userNo +
        "&status=" +
        this.status +
        "&size=" +
        this.pageSize +
        "&current=" +
        this.currentPage;
      this.$axios.post("/member/list", data).then(result => {
        if (result.data.status == 0) {
          this.couponList = result.data.data.records;
          this.total = result.data.data.total;
          this.page = Math.ceil(result.data.data.total / this.pageSize);
          this.couponList.forEach(item => {
            item.overdue = item.overdue == 1 ? "有效" : "过期";
          });
        }
      });
    }
  }
};
</script>


<style lang="less" >
.homeSetUp-container {
  @import "../../style/table.less";
  @import "../../style/content.less";
  display: flex;
  flex-flow: column;
  position: relative;
  height: 100%;
  .el-table .cell {
    white-space: pre-line !important;
  }
  .content {
    .query {
      .el-form-item {
        margin-bottom: 8px !important;
      }
      .start_time {
        display: flex;
        align-items: center;
      }
      .end_time {
        display: flex;
        align-items: center;
      }
      .btn {
        .el-button {
          width: 70px;
        }
      }
    }
  }
}
</style>

